﻿namespace Sidvall.AuthorizationManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class AuthorizationScopeResourceAction : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction
    {
        #region Public Members

        #region AccessLevel

        private global::Sidvall.AuthorizationManager.Data.ResourceAccessLevel _AccessLevel;
        partial void OnBeforeAccessLevelPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.AuthorizationManager.Data.ResourceAccessLevel> eventData);
        partial void OnAfterAccessLevelPropertyChanged();
        public global::Sidvall.AuthorizationManager.Data.ResourceAccessLevel AccessLevel
        { 
            get
            {
                return _AccessLevel;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AccessLevel = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<global::Sidvall.AuthorizationManager.Data.ResourceAccessLevel> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.AuthorizationManager.Data.ResourceAccessLevel>(value, _AccessLevel);
                    OnBeforeAccessLevelPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AccessLevel", eventData.Value, true, true);
                        OnAfterAccessLevelPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region Actions

        private string _Actions;
        partial void OnBeforeActionsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterActionsPropertyChanged();
        public string Actions
        { 
            get
            {
                return _Actions;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Actions = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Actions);
                    OnBeforeActionsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Actions", eventData.Value, true, true);
                        OnAfterActionsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region AuthorizationScopeId

        private long _AuthorizationScopeId;
        partial void OnBeforeAuthorizationScopeIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<long> eventData);
        partial void OnAfterAuthorizationScopeIdPropertyChanged();
        public long AuthorizationScopeId
        { 
            get
            {
                return _AuthorizationScopeId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AuthorizationScopeId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<long> eventData = new Sidvall.Business.PropertyChangeEventData<long>(value, _AuthorizationScopeId);
                    OnBeforeAuthorizationScopeIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AuthorizationScopeId", eventData.Value, true, true);
                        OnAfterAuthorizationScopeIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region AuthorizationScopeResourceActionId

        private System.Nullable<long> _AuthorizationScopeResourceActionId;
        partial void OnBeforeAuthorizationScopeResourceActionIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterAuthorizationScopeResourceActionIdPropertyChanged();
        public System.Nullable<long> AuthorizationScopeResourceActionId
        { 
            get
            {
                return _AuthorizationScopeResourceActionId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AuthorizationScopeResourceActionId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _AuthorizationScopeResourceActionId);
                    OnBeforeAuthorizationScopeResourceActionIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AuthorizationScopeResourceActionId", eventData.Value, true, true);
                        OnAfterAuthorizationScopeResourceActionIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled;
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        { 
            get
            {
                return _IsEnabled;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IsEnabled = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                    OnBeforeIsEnabledPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IsEnabled", eventData.Value, true, true);
                        OnAfterIsEnabledPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region Resources

        private string _Resources;
        partial void OnBeforeResourcesPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterResourcesPropertyChanged();
        public string Resources
        { 
            get
            {
                return _Resources;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Resources = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Resources);
                    OnBeforeResourcesPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Resources", eventData.Value, true, true);
                        OnAfterResourcesPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region SubActions

        private string _SubActions;
        partial void OnBeforeSubActionsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSubActionsPropertyChanged();
        public string SubActions
        { 
            get
            {
                return _SubActions;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _SubActions = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _SubActions);
                    OnBeforeSubActionsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("SubActions", eventData.Value, true, true);
                        OnAfterSubActionsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region ValidForResourceActionItems

        private bool _ValidForResourceActionItems;
        partial void OnBeforeValidForResourceActionItemsPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterValidForResourceActionItemsPropertyChanged();
        public bool ValidForResourceActionItems
        { 
            get
            {
                return _ValidForResourceActionItems;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _ValidForResourceActionItems = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _ValidForResourceActionItems);
                    OnBeforeValidForResourceActionItemsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("ValidForResourceActionItems", eventData.Value, true, true);
                        OnAfterValidForResourceActionItemsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        
        public AuthorizationScope AuthorizationScope { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public AuthorizationScopeResourceActionClaimCollectionItem AuthorizationScopeResourceActionClaims { get; set; }
        #region LoadAuthorizationScopeResourceActionClaims

        public void LoadAuthorizationScopeResourceActionClaims(AuthorizationScopeResourceActionClaimCollectionItem value)
        {
            LoadInstanceField("AuthorizationScopeResourceActionClaims", value, true, false);
        }

        #endregion
        #region LoadAuthorizationScopeResourceActionClaimsAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceActionClaimCollectionItem> LoadAuthorizationScopeResourceActionClaimsAsync()
        {
            return await LoadAuthorizationScopeResourceActionClaimsAsync(false, true, null, null, null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceActionClaimCollectionItem> LoadAuthorizationScopeResourceActionClaimsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceActionClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceActionClaimRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionManager.LoadAuthorizationScopeResourceActionClaimsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters).ConfigureAwait(false);

            return this.AuthorizationScopeResourceActionClaims;
        }

        #endregion
        #region LoadAuthorizationScopeAsync

        public async System.Threading.Tasks.Task<AuthorizationScope> LoadAuthorizationScopeAsync()
        {
            return await LoadAuthorizationScopeAsync(false, true, null, null, null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScope> LoadAuthorizationScopeAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionManager.LoadAuthorizationScopeAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters).ConfigureAwait(false);

            return this.AuthorizationScope;
        }
        public AuthorizationScope LoadAuthorizationScope(AuthorizationScope item)
        {
            LoadInstanceField("AuthorizationScope", item, true, false);
            return item;
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public AuthorizationScopeResourceAction Copy()
        {
            return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Copy(this);
        }
        public AuthorizationScopeResourceAction Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction item)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Import(this, item);
        }
        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Import(this, item, settings);
        }

        #endregion
        #region SaveItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceAction> SaveItemAsync()
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionManager.SaveItemAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceAction> SaveItemAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionManager.SaveItemAsync(this, mode).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceAction> SaveItemAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionManager.SaveItemAsync(this, settings).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceAction> SaveItemAsync(Sidvall.Data.SaveSettings settings, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionManager.SaveItemAsync(this, settings, strategyContext, objectParameters).ConfigureAwait(false);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Initialize(this, settings);
        }

        #endregion

        #region IAuthorizationScopeResourceAction Members

        global::Sidvall.AuthorizationManager.Data.ResourceAccessLevel global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.AccessLevel
        {
            get
            {
                return this._AccessLevel;
            }
            set
            {
                this._AccessLevel = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.Actions
        {
            get
            {
                return this._Actions;
            }
            set
            {
                this._Actions = value;
            }
        }
        long global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.AuthorizationScopeId
        {
            get
            {
                return this._AuthorizationScopeId;
            }
            set
            {
                this._AuthorizationScopeId = value;
            }
        }
        System.Nullable<long> global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.AuthorizationScopeResourceActionId
        {
            get
            {
                return this._AuthorizationScopeResourceActionId;
            }
            set
            {
                this._AuthorizationScopeResourceActionId = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.Resources
        {
            get
            {
                return this._Resources;
            }
            set
            {
                this._Resources = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.SubActions
        {
            get
            {
                return this._SubActions;
            }
            set
            {
                this._SubActions = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.ValidForResourceActionItems
        {
            get
            {
                return this._ValidForResourceActionItems;
            }
            set
            {
                this._ValidForResourceActionItems = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.IAuthorizationScope global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.AuthorizationScope
        {
            get
            {
                return this.AuthorizationScope;
            }
            set
            {
                this.AuthorizationScope = (AuthorizationScope)value;
            }
        }
        System.Collections.Generic.IEnumerable<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim> global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.AuthorizationScopeResourceActionClaims
        {
            get
            {
                if (this.AuthorizationScopeResourceActionClaims != null)
                    return this.AuthorizationScopeResourceActionClaims.Items;
                return null;
            }
        }
        void global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction.SetAuthorizationScopeResourceActionClaims(Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim> items)
        {
            this.AuthorizationScopeResourceActionClaims = (AuthorizationScopeResourceActionClaimCollectionItem)items;
        }

        #endregion

        #endregion
        #region Constructors

        public AuthorizationScopeResourceAction()
        {
        }
        public AuthorizationScopeResourceAction(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public AuthorizationScopeResourceAction(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionManager.Initialize(this);
        }

        #endregion
    }
}